﻿<!--#include file="inc/conn.asp"-->
<%
Call OpenData()
CityJs = CityJs & "var District = ["
set rsJsP = server.CreateObject("adodb.recordset")
sqlJsP = "select ID,CityName,EnName from [City] where RootID = 0 order by OrderID"
rsJsP.open sqlJsP,conn,1,1
	for i = 1 to rsJsP.recordcount
		PID = rsJsP("ID")
		PCityName = rsJsP("CityName")
		PEnName = rsJsP("EnName")
		CityJs = CityJs & "{ID:"&PID&",Name:'"&PCityName&"',EnName:'"&Lcase(PEnName)&"'"
		set rsJsC = server.CreateObject("adodb.recordset")
		sqlJsC = "select ID,CityName from [City] where RootID ="&PID&" order by OrderID"
		rsJsC.open sqlJsC,conn,1,1
		if not rsJsC.eof then
			CityJs = CityJs & ",City:["
			for j = 1 to rsJsC.recordcount
				CID = rsJsC("ID")
				CCityName = rsJsC("CityName")
				CityJs = CityJs & "{ID:"&CID&",Name:'"&CCityName&"'"
				if j = rsJsC.recordcount then
					CityJs = CityJs & "}"
				else
					CityJs = CityJs & "},"
				end if
			rsJsC.movenext
			next
			CityJs = CityJs & "]"
		end if
		if i = rsJsP.recordcount then
			CityJs = CityJs & "}"
		else
			CityJs = CityJs & "},"
		end if
	rsJsP.movenext
	next
rsJsC.close
set rsJsC = nothing
rsJsP.close
set rsJsP = nothing
CityJs = CityJs & "];"&vbcrlf
response.Write(CityJs)
Call CloseData()
%> 